<%--
  Created by IntelliJ IDEA.
  User: bryant
  Date: 10/31/12
  Time: 2:34 PM
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="s" uri="/struts-tags" %>
<%@ taglib prefix="display" uri="http://displaytag.sf.net" %>
<%@ taglib prefix="code" uri="/WEB-INF/tld/code.tld" %>
<title>客户查询</title>
<script type="text/javascript">
    $(document).ready(function () {
        $("#checkAll").click(
                function(){
                    if(this.checked){
                        $("input[name='checkBox']").each(function(){this.checked=true;});
                    }else{
                        $("input[name='checkBox']").each(function(){this.checked=false;});
                    }
                }
        );
    });

    function deleteMultiRecords(){
        var selected = false;
        $("input[name='checkBox']").each(
                function(){
                    if(this.checked==true){
                        selected = true;
                        $("#customerSearch").attr("action","customer_delete").submit();
                    }
                });
        if(!selected)
            $("#attentionSelect").show();
    }

</script>
<%
    String path = request.getContextPath();
%>
<form id="customerSearch" action="customer_search" method="post">
    <div id="main-content">
        <s:if test="hasActionMessages()">
            <div class="notification success png_bg"><a href="#" class="close"><img
                    src="<%=path%>/images/icons/cross_grey_small.png" title="Close this notification" alt="close"/></a>

                <div><s:actionmessage/></div>
            </div>
        </s:if>
        <div id="attentionSelect" style="display: none;" class="notification attention png_bg">
            <a href="#" class="close"><img src="<%=path %>/images/icons/cross_grey_small.png" title="Close this notification" alt="close" /></a>
            <div> 请至少选择一条记录 </div>
        </div>
        <div>
            <table>
                <tr>
                    <td width="9%"><label>客户姓名</label></td>
                    <td colspan="3"><s:textfield name="customer.customerName" cssClass="text-input small-input"/><br/>
                        <%--<small>输入商品名称</small>--%>
                    </td>
                </tr>
                <tr>
                <td><label>客户地址</label></td>
                    <td> <code:codeSelect id='municipio' name="customer.municipioId" cdTypeId="5"  cssClass="validate[required]" headerKey="" headerValue="请选择"/>
                        &nbsp;
                        <s:select list="townList" name="customer.townId" id='town'  headerKey="" headerValue="请选择" listKey="codeId" listValue="codeDesc"/>
                        <s:select list="villageList" name="customer.villageId" id='village' headerKey="" headerValue="请选择" listKey="codeId" listValue="codeDesc"/>
                    </td>
                </tr>
                <tr>
                    <td><label>手机号码</label></td>
                    <td>
                        <s:textfield name="customer.mobileNo" cssClass="text-input small-input"/>
                    </td>
                </tr>
                <tr>
                    <td><label>座机号码</label></td>
                    <td>
                        <s:textfield name="customer.telephoneNo" cssClass="text-input small-input"/>
                    </td>
                </tr>
                <tr>
                    <td colspan="4">
                        <input class="button" align="center" type="submit" value="查询"/>
                        &nbsp;
                        <input class="button" align="center" type="reset" value="重设" />
                    </td>
                </tr>
            </table>
        </div>
        <div class="content-box">
            <div class="content-box-header" align="center">
                <h3>查询结果</h3>
            </div>
            <s:if test="paginatedList!=null">
            <div class="content-box-content">
                <div class="tab-content default-tab" id="tab1">
                    <display:table name="paginatedList" requestURI="customer_search" sort="external"  id="row">
                        <display:column title='<input type="checkbox" id="checkAll"/>'>
                            <input type="checkbox" name="checkBox" value="${row.id}">
                        </display:column>
                        <display:column property="customerName" sortProperty="customer_name" title="客户姓名" sortable="true" headerClass="sortable"/>
                        <display:column property="address" sortProperty="address" title="客户地址" sortable="true" headerClass="sortable"/>
                        <display:column property="mobileNo" sortProperty="mobile_no" title="手机号码" sortable="true" headerClass="sortable"/>
                        <display:column property="telephoneNo" sortProperty="telephone_no" title="座机号码" sortable="true" headerClass="sortable"/>
                        <display:column property="onCreated" sortProperty="on_created" format="{0,date,dd-MM-yyyy HH:mm:ss}" title="创建日期" sortable="true" headerClass="sortable"/>
                        <display:column paramId="sid" paramProperty="id" title='&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a title="Delete" href="#" onClick="deleteMultiRecords();"><img  src="/ocgs-admin/images/icons/cross.png"></a>'>
                            <a title="Edit" href="customer_linkCustomerUpdatePage?customer.id=${row.id}"><img alt="Edit" src="<%=path %>/images/icons/pencil.png"></a>
                            <a title="Delete" href="customer_delete?customer.id=${row.id}"><img alt="Delete" src="<%=path %>/images/icons/cross.png"></a>
                        </display:column>
                    </display:table>
                </div>
            </div>
            </s:if>
        </div>
    </div>
</form>